home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / JTools / Demos / bench_primitives < prev    next >
Encoding:
Text File  |  1991-08-14  |  1.3 KB  |  40 lines

  1. \ Benchmark Forth Primitives
  2. \
  3. \ These should run on almost any 32 bit Forth.
  4. \ ( You may have to remove the commas.)
  5. \
  6. \ This code is provided as an example of using
  7. \ JForth benchmark utilities.
  8. \ If you don't have words like BENCH.WITH, use
  9. \ your stopwatch on your previous Forth.
  10. \
  11. \
  12. \ Copyright 1986 Delta Research
  13.  
  14. \ Examine this file for details.
  15. include? bench ju:measure  \ Resolution of 1/50 second.
  16.  
  17. decimal
  18.  
  19. create #do 1,000,000   ,
  20.  
  21. : t1           #do @ 0      do                     loop ;
  22. : t2  23 45    #do @ 0      do  swap               loop   2drop ;
  23. : t3  23       #do @ 0      do  dup drop           loop drop ;
  24. : t4  23 45    #do @ 0      do  over drop          loop 2drop ;
  25. : t5           #do @ 0      do  23 45 + drop       loop ;
  26. : t6  23       #do @ 0      do  >r r>              loop drop ;
  27. : t7  23 45 67 #do @ 0      do  rot                loop 2drop drop ;
  28. : t8           #do @ 0      do  23 2* drop         loop  ;
  29. : t9           #do @ 10 / 0 do  23 5 /mod 2drop    loop ;
  30. : t10     #do  #do @ 0      do  dup @ drop         loop drop ;
  31.  
  32. : foo ( noop ) ;
  33. : t11          #do @ 0      do  foo                loop ;
  34.  
  35. ." To initialize DO LOOP timing correction, enter:" cr
  36. ."      BENCH.WITH T1" cr
  37. cr
  38. ." Then to test T6, for example:" cr
  39. ."      BENCH T6     ... and so on." cr
  40.